package type1;

import type1.CurrentConditions;

/**
 * @projectName: com.xiayuanxing.designPattern
 * @className: type1.WeatherData
 * @author: xiayuanxing
 * @description: TODO
 * @date: 2022/1/7 15:53
 * @version: 1.0
 */
public class WeatherData {

    //温度
    private float temperature;
    //气压
    private float pressure;
    //湿度
    private float humidity;

    private CurrentConditions currentConditions;

    /** 构造函数 */
    public WeatherData(CurrentConditions currentConditions) {
        this.currentConditions = currentConditions;
    }

    public float getTemperature() {
        return temperature;
    }

    public float getPressure() {
        return pressure;
    }

    public float getHumidity() {
        return humidity;
    }

    public void dataChange(){
        //调用接入方的update
        currentConditions.update(getTemperature(),getPressure(),getHumidity());
    }

    public void setData(float temperature,float pressure,float humidity){
        this.temperature = temperature;
        this.pressure = pressure;
        this.humidity = humidity;
        //调用dataChange，将最新的信息推送给接入方currentConditions
        dataChange();
    }
}
